﻿using System.Collections.Generic;

namespace FluentWebRequest
{
    internal class RequestItem : IRequestItem
    {
        private readonly IRequestDataBuilder _requestDataBuilder;
        private IDictionary<string, string> _requestItems;
        private readonly string _url;

        public RequestItem(IRequestDataBuilder requestDataBuilder, string url, IDictionary<string, string> requestItems)
        {
            _url = url;
            _requestDataBuilder = requestDataBuilder;
            _requestItems = requestItems;
        }

        public IRequestItemName WithNameIs(string name)
        {
            _requestItems.Add(name, string.Empty);

            return new RequestItemName(_requestDataBuilder, _url, _requestItems, name);
        }

        public IRequestItem ReplaceRequestItems(IDictionary<string, string> requestItems)
        {
            _requestItems = requestItems;
            return this;
        }
    }
}